<?php
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require_once('config.php');
require_once('qq.php');
include_once( 'wbconfig.php' );
include_once( 'saetv2.ex.class.php' );
$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );
$code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );
if($qq_t!=''){
    $qq=new qqPHP($qq_k, $qq_s, $qq_t);
    $qq_oid=$qq->get_openid();
    $openid=$qq_oid['openid']; //获取登录用户open id
    //获取登录用户信息
    $result=$qq->get_user_info($openid);
//	 echo "<script type='text/javascript'>alert('使用QQ快捷登录成功');location.href='qqwelcome.php';</script>";
//    exit;
}else{
    //生成登录链接
    $qq=new qqPHP($qq_k, $qq_s);
    $login_url=$qq->login_url($callback_url, $scope);
}
if($_GET['act']=='login'){
    $sql = "select * from tbl_user where userid ='".$_POST['userid']."' AND userpwd ='".$_POST['userpwd']."'";
    $query = mysql_query($sql);
    $row = mysql_fetch_array($query);
    if($row){
        setcookie("username",$row['userid'],time()+(3600*8*1*1),"/");
        setcookie("userid",$row['id'],time()+(3600*8*1*1),"/");
        setcookie("shuyu",$row['shuyu'],time()+(3600*8*1*1),"/");
        setcookie("addmima",strtotime($row['change_pwd_time']),time()+(3600*8*1*1),"/");
//	
        if($_COOKIE['popped']){
            echo "<script type='text/javascript'>location.href='".$_COOKIE['popped']."';</script>";
        }else {
            echo "<script type='text/javascript'>location.href='mlogin.php';</script>";
        }
    } else{
        echo "<script type='text/javascript'>alert('用户名或密码不正确');location.href='mlogin.php';</script>";
        exit;
    }
}

if($_COOKIE['userid']){
    echo "<script type='text/javascript'>location.href='main.php';</script>";
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>会员登录-众晒网</title>
    <link rel="stylesheet" href="/ui/login/css/base.css" />
    <style>
        ::-webkit-input-placeholder {
            /* WebKit browsers */
            color: #CCCCCC!important;
        }

        :-moz-placeholder {
            /* Mozilla Firefox 4 to 18 */
            color: #CCCCCC!important;
        }

        ::-moz-placeholder {
            /* Mozilla Firefox 19+ */
            color: #CCCCCC!important;
        }

        :-ms-input-placeholder {
            /* Internet Explorer 10+ */
            color: #CCCCCC!important;
        }

        #geetest_holder geetest_wind geetest_radar_click_hide{
            width:  261px;
        }
        #embed-captcha {
            width:  261px;
            margin: 7px auto;
        }
        .show {
            display: block;
        }
        .hide {
            display: none;
        }
        .t {
            margin-left:13px;
            text-decoration:none;
        }
        .nav {
            margin-top: 2%;
            height: auto;
            overflow: hidden;
            padding-bottom: 2rem;
        }
        .nav ul {
            height: auto;
            overflow: hidden;
            clear: both;
        }
        .nav ul li {
            width: 15%;
            float: left;
            margin-left: 13%;
            font-size: 1.2rem;
            text-align: center;
            margin-top: 2rem;
            line-height: 1.5rem;
        }
        .nav ul li img {
            width: 100%;
            -webkit-animation-delay: 1.5s;
            -webkit-animation-duration: 2s;
        }
        #notice {
            color: red;
        }



        a{
            text-decoration:none;
            color:#FE984C;


        }
        input[type="checkbox"] {
            height: 10px;
        }


    </style>
</head>
<body>
<div class="bg_bank">
    <a class="re_bank" href="javascirpt:;" onclick="javascript:history.back(-1);"></a>
    <div class="re_min_infor">
        <form  action="?act=login" method="post"  name="myform" onSubmit="return beforeSubmit(this);">
            <div class="bg_color">
                <div class="re_min">
                    <span class="icon_phone"></span>
                    <input class="input01" name="userid" type="text" placeholder="请输入手机号" /><div id="div1"></div>
                </div>
                <div class="re_min">
                    <span class="icon_passwarde"></span>
                    <input class="input01" name="userpwd" type="password" placeholder="请输入密码" />

                </div>
                <div class="re_min" id="embed-captcha" name="embed-captcha">
                    <p id="wait" class="show">正在加载验证码......</p>
                    <p id="notice" class="hide">请先完成验证</p>
                </div>
                <input type="checkbox" checked="checked"  name="tongyi" /><lable>我已认真阅读并同意<a href="xieyi.php" >《众晒网用户协议》</a>及<a href="ys.php">《众晒网隐私政策》。</a></label>
            </div>
            <div class="re_regist" style="margin-top:-23px;">
                <button class="btn_regist" id="embed-submit" type="submit">登录</button>
            </div>

            <div class="re_regist" style="margin-top:11px;">
                <button onclick="window.location.href='mlogin.php'" class="btn_regist" type="button" style="background-color: #cccccc;border: 1px solid #cccccc;">验证码登录</button>
            </div>

            <div class="re_regist02">
                <!------------
                    <a class="t" id="dl"  style="text-decoration:none;color: #fe984c;">注册</a>
                ------------------------>
                <a class="t" href="mmregister.php"  style="text-decoration:none;color: #fe984c;">注册</a>
                <a class="t" href="javascript:void(0)" onclick="_MEIQIA('showPanel')" style="text-decoration:none;color: #fe984c;" >客服</a>

                <a class="t" href="xiugaimima.php"  style="text-decoration:none;color: #fe984c;">忘记密码</a>
            </div>
            <div class="nav">
                <ul>
                    <li>
                        <a href="<?=$login_url?>">
                            <p><img src="/ui/login/img/icon_QQ登录@3x.png" class="animated bounceIn"></p>
                        </a>
                    </li>
                    <li>
                        <?php

                        // 是否微信中打开
                        function is_weixin() {
                            if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
                                return true;
                            } return false;
                        }
                        $is_weixin = (is_weixin() == true) ? "1" : "2";
                        ?>
                        <?php
                        if($is_weixin==1){
                            ?>
                            <a href="wxlogin.php">
                                <p><img src="/ui/login/img/微信登录@3x.png" class="animated rotateIn"></p>
                            </a>
                        <?php } ?>
                        <?php
                        if($is_weixin==2){
                            ?>
                            <a href="javascirpt:;" onclick="alert('请在微信APP中打开!');">
                                <p><img src="/ui/login/img/微信登录@3x.png" class="animated rotateIn"></p>
                            </a>
                        <?php } ?>
                    </li>
                    <li>
                        <a href="<?=$code_url?>">
                            <p><img src="/ui/login/img/微博登录@3x.png" class="animated rotateIn"></p>
                        </a>
                    </li>
                </ul>
            </div>
        </form>
    </div>
</div>
<script src="/ui/js/ui.js"></script>
<script src="static/gt.js"></script>
<script src="/wap/dl/lib/jquery-2.1.4.js"></script>
<script src="/wap/dl/lib/fastclick.js"></script>
<script type="text/javascript" src="/ui/layer/mobile/layer.js"></script>
<script>
    var _mtac = {};
    (function() {
        var mta = document.createElement("script");
        mta.src = "http://pingjs.qq.com/h5/stats.js?v2.0.2";
        mta.setAttribute("name", "MTAH5");
        mta.setAttribute("sid", "500475478");
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(mta, s);
    })();
</script>
<!-- 这是美洽的嵌入代码 -->
<!-- 这是美洽的嵌入代码 -->
<script type='text/javascript'>
    (function(m, ei, q, i, a, j, s) {
        m[i] = m[i] || function() {
            (m[i].a = m[i].a || []).push(arguments)
        };
        j = ei.createElement(q),
            s = ei.getElementsByTagName(q)[0];
        j.async = true;
        j.charset = 'UTF-8';
        j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
        s.parentNode.insertBefore(j, s);
    })(window, document, 'script', '_MEIQIA');
    _MEIQIA('entId', '65407');

    // 在这里开启无按钮模式（常规情况下，需要紧跟在美洽嵌入代码之后）
    _MEIQIA('withoutBtn');
</script>
<script type='text/javascript'>
    // 当你使用了「手动初始化」时，就可以在自己的逻辑中选择合适的时机调用 withoutBtn
    // 只要是在美洽初始化之前，就可以被正确执行
    _MEIQIA('withoutBtn');
    _MEIQIA('init');
</script>

<!-- 这是美洽的嵌入代码 -->

<script>
    var handlerEmbed = function (captchaObj) {
        $("#embed-submit").click(function (e) {
            var validate = captchaObj.getValidate();
            if (!validate) {
                $("#notice")[0].className = "show";
                setTimeout(function () {
                    $("#notice")[0].className = "hide";
                }, 2000);
                e.preventDefault();
            }
        });
        // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
        captchaObj.appendTo("#embed-captcha");
        captchaObj.onReady(function () {
            $("#wait")[0].className = "hide";
        });
        // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
    };
    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: "yz/StartCaptchaServlet.php?t=" + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            console.log(data);
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                new_captcha: data.new_captcha,
                product: "embed", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
                // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
            }, handlerEmbed);
        }
    });
</script>
<script type="text/javascript">
    function beforeSubmit(form){
        if(form.userid.value==''){

            layer.open({
                content: '请填写手机号'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });



            return false;

        }
        if(form.userpwd.value==''){

            layer.open({
                content: '请填写密码'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });



            return false;

        }

        return true;

    }

</script>
<script>
    var name=document.getElementById('tongyi');
    if(name.checked=false){
        alert("请先同意协议");
    };
</script>
</body>
</html>